<!-- templates/profile.html -->
<!DOCTYPE html>
<html>
<head>
    <title>个人管理</title>
    {% load static %}
    <style>        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
        }
        .profile-info {
            text-align: center;
            width: 300px;
        }
        img {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            margin-bottom: 20px;
        }
        .container {
            display: flex;
            width: 80%;
            max-width: 1200px;
            background-color: #ffffff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            margin: auto;
        }
        .left-panel, .right-panel {
            padding: 20px;
        }
        .left-panel {
            width: 30%;
            border-right: 1px solid #ddd;
        }
        .right-panel {
            width: 70%;
        }
        .profile-buttons {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-top: 20px;
        }
        .profile-buttons a, .profile-buttons button {
            padding: 10px 20px;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            text-decoration: none;
            margin-bottom: 10px;
        }
        .profile-buttons a:hover, .profile-buttons button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="left-panel">
            <div class="profile-info">
                {% if request.user.profile.avatar %}
                    <img src="{{ request.user.profile.avatar.url }}" alt="头像">
                {% else %}
                    <img src="{% static 'image/avatar.jpg' %}" alt="默认头像">
                {% endif %}
                <h3>{{ request.user.username }}</h3>
                <p>{{ request.user.email }}</p>
            </div>
            <div class="profile-buttons">
                <a href="{% url 'admin:index' %}">我的后台</a>
                <a href="{% url 'logout' %}">退出登录</a>
                <a href="{% url 'password_change' %}">修改密码</a>
            </div>
        </div>
        <div class="right-panel">
            {% block right-panel %}
                <h2>修改个人信息</h2>
                <form method="post" enctype="multipart/form-data">
                    {% csrf_token %}
                    {{ user_form.as_p }}
                    {{ profile_form.as_p }}
                    <button type="submit">保存</button>
                </form>
            {% endblock %}
        </div>
    </div>
</body>
</html>
